pkglist=`cat pkglist`
ziplist=`find openEuler -iname "*.zip"`
gzlist=`find openEuler -iname "*.tar.gz"`
bz2list=`find openEuler -iname "*.tar.bz2"`
xzlist=`find openEuler -iname "*.tar.xz"`


for z in $ziplist
do
    if [[ $z =~ "openEuler/iptables/" ]];then
        continue
    fi
    d=${z%.*}
    mkdir -p "greptmp/$d"
    unzip $z -d "greptmp/$d"
done

for g in $gzlist
do
    if [[ $g =~ "openEuler/iptables/" ]];then
        continue
    fi
    d=`dirname $g`
    mkdir -p "greptmp/$d"
    tar -zxvf $g -C "greptmp/$d"	
done

for b in $bz2list
do
    if [[ $b =~ "openEuler/iptables/" ]];then
        continue
    fi
    d=`dirname $b`
    mkdir -p "greptmp/$d"
    tar -xvf $b -C "greptmp/$d"
done

for x in $xzlist
do
    if [[ $x =~ "openEuler/iptables/" ]];then
        continue
    fi
    d=`dirname $x`
    mkdir -p "greptmp/$d"
    tar -xvJf $x -C "greptmp/$d"
done

echo "==================================start ============" > grepresult.txt
for pkg in $pkglist
do
    grep -Rn $1 openEuler/$pkg >> grepresult.txt
done

echo "========================================================================" >> grepresult.txt
grep -Rn $1 greptmp/* >> grepresult.txt

rm -rf greptmp/*
